#!/bin/gawk -f
# Summarize RESTRAINT_VIOLATION_SUMMARY containing av/rmsd from .nrc/.hrc/.src file
# Arguments: sel: record to select

NR==sel || sel==0 {
    if ( !sel ) print toupper( $1 )
    printf("\n%s: Total UPPER BOUND violation: %.2f\n", $1, $4)
    printf("%s: Number of violated restraints: %5i, Average violation: %.2f +/- %.2f\n", $1, $2, $5, $6)
    printf("%s: Number of restraints:          %5i, Average violation: %.2f +/- %.2f\n", $1, $NF, $7, $8)
    tot = $11
    if ( tot < 0. ) tot = -tot
    printf("\n%s: Total LOWER BOUND violation: %.2f\n", $1, tot)
    av = $12
    if ( av < 0. ) av = -av
    printf("%s: Number of violated restraints: %5i, Average violation: %.2f +/- %.2f\n", $1, $9, av, $13)
    av = $14
    if ( av < 0. ) av = -av
    printf("%s: Number of restraints:          %5i, Average violation: %.2f +/- %.2f\n\n", $1, $NF, av, $15)
    if (sel) exit
}
